package com.dao.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import com.bean.TopicTable;
import com.dao.TopicTableDao;
@Component
public class TopicTableDaoImpl implements TopicTableDao{

	
	@Autowired
	private MongoTemplate mongoTemplate;
	
	public Map<String,Object>  findLineTables(){
		Map<String, Object> map=new HashMap<String, Object>();
		List<TopicTable> lineTables=mongoTemplate.find(new Query(Criteria.where("isDelete").is("n")), TopicTable.class);
		List<TopicTable> top=new ArrayList<TopicTable>();
		List<TopicTable> button=new ArrayList<>();
		if (lineTables!=null) {
			for (TopicTable lineTable : lineTables) {
				if (lineTable.getType().equalsIgnoreCase("top")) {
					top.add(lineTable);
				} else {
					button.add(lineTable);
				}
			}
		}
		map.put("top", top);
		map.put("button", button);
		return map;
	}
}
